/**
 * Created with IntelliJ IEDA.
 * Description:
 * User:86186
 * Date:2022-09-01
 * Time:17:03
 */

/**
 * 力扣387:字符串中第一个唯一字符
 */
public class firstUniqChar {
    public static void main(String[] args) {
        System.out.println("hell");
    }
    public int firstUniqChar1(String s) {
        int[] words = new int[26];
        char[] ch = s.toCharArray();
        for (int i = 0; i < ch.length; i++) {
            int num = (int)ch[i];
            words[num-97]++;
        }
        for (int i = 0; i < ch.length; i++) {
            int num = (int)ch[i] - 97;
            if (words[num] == 1){
                return i;
            }
        }
        return -1;
    }
}
